package database;

import Other.Glob;
import enums.SearchType;

public class MyShipment extends NewTirDataBase{
	
	private String shipmentID;
	private String clientCodeID;
	private String clientName;
	private String addresseeCodeID;
	private String addresseeName;
	private String invoice;
	private String rDate;
	private String destinationCodeID;
	private String destinationName;
	private String dDate;
	private String currency;
	private String kilos;
	private String volume;
	private String incotermCodeID;
	private String incotermName;
	private String comment1;
	private String comment2;
	private String transportID;
	
	String data[];
	
	private static final int SHIPMENT_ID = 0;
	private static final int CLIENT_CODE_ID = 1 ;
	private static final int ADDRESSEE_CODE_ID = 2;
	private static final int INVOICE = 3;
	private static final int R_DATE = 4;
	private static final int DESTINATION_CODE_ID = 5;
	private static final int D_DATE = 6;
	private static final int CURRENCY = 7;
	private static final int KILOS = 8;
	private static final int VOLUME = 9;
	private static final int INCOTERM_CODE_ID = 10;
	private static final int COMMENT_1 = 11;
	private static final int COMMENT_2 = 12;
	private static final int TRANSPORT_ID = 13;
	
	MyShipment () {
		
		
	}

	public MyShipment(String[] data) {
		super();
		
		this.shipmentID = data[SHIPMENT_ID];
		this.clientCodeID = data[CLIENT_CODE_ID];
		this.addresseeCodeID = data[ADDRESSEE_CODE_ID];
		this.invoice = data[INVOICE];
		this.rDate = data[R_DATE];
		this.destinationCodeID = data[DESTINATION_CODE_ID];
		this.dDate = data[D_DATE];
		this.currency = data[CURRENCY];
		this.kilos = data[KILOS];
		this.volume = data[VOLUME];
		this.incotermCodeID = data[INCOTERM_CODE_ID];
		this.comment1 = data[COMMENT_1];
		this.comment2 = data[COMMENT_2];
		this.transportID = data[TRANSPORT_ID];
		
		
		clientName = "";
		
Glob.type = SearchType.CLIENT;
		
		
		for (NewTirDataBase c : DatabaseExtension.getTableID("Select * from client")) {
			if (((MyClient) c).getClientID().trim().replaceAll("\n", "").equals(clientCodeID)) {
				clientName = String.format("%s",((MyClient) c).getName());
			}
				
		}
		
		Glob.type = SearchType.ADDRESSEE;
		addresseeName = "";
		
		for (NewTirDataBase c : DatabaseExtension.getTableID("Select * from addressee")) {
			if (((MyAddressee) c).getAddresseeID().trim().replaceAll("\n", "").equals(addresseeCodeID)) {
				addresseeName = String.format("%s",((MyAddressee) c).getName());
			}
				
		}
		
		Glob.type = SearchType.DESTINATION;
		destinationName = "";
		
		for (NewTirDataBase c : DatabaseExtension.getTableID("Select * from destination")) {
			if (((MyDestination) c).getDestinationID().trim().replaceAll("\n", "").equals(destinationCodeID)) {
				destinationName = String.format("%s",((MyDestination) c).getName());
			}
				
		}
		
		Glob.type = SearchType.INCOTERM;
		incotermName = "";
		
		for (NewTirDataBase c : DatabaseExtension.getTableID("Select * from incoterm")) {
			if (((MyIncoterm) c).getIncotermID().trim().replaceAll("\n", "").equals(incotermCodeID)) {
				incotermName = String.format("%s",((MyIncoterm) c).getIncotermName());
			}
				
		}
		
		Glob.type = SearchType.SHIPMENT;
		
		
	}

	public String getShipmentID() {
		return shipmentID;
	}

	public void setShipmentID(String shipmentID) {
		this.shipmentID = shipmentID;
	}

	public String getClientCodeID() {
		return clientCodeID;
	}

	public void setClientCodeID(String clientCodeID) {
		this.clientCodeID = clientCodeID;
	}

	public String getClientName() {
		return clientName;
	}

	public void setClientName(String clientName) {
		this.clientName = clientName;
	}

	public String getAddresseeCodeID() {
		return addresseeCodeID;
	}

	public void setAddresseeCodeID(String addresseeCodeID) {
		this.addresseeCodeID = addresseeCodeID;
	}

	public String getAddresseeName() {
		return addresseeName;
	}

	public void setAddresseeName(String addresseeName) {
		this.addresseeName = addresseeName;
	}

	public String getInvoice() {
		return invoice;
	}

	public void setInvoice(String invoice) {
		this.invoice = invoice;
	}

	public String getrDate() {
		return rDate;
	}

	public void setrDate(String rDate) {
		this.rDate = rDate;
	}

	public String getDestinationCodeID() {
		return destinationCodeID;
	}

	public void setDestinationCodeID(String destinationCodeID) {
		this.destinationCodeID = destinationCodeID;
	}

	public String getDestinationName() {
		return destinationName;
	}

	public void setDestinationName(String destinationName) {
		this.destinationName = destinationName;
	}

	public String getdDate() {
		return dDate;
	}

	public void setdDate(String dDate) {
		this.dDate = dDate;
	}

	public String getCurrency() {
		return currency;
	}

	public void setCurrency(String currency) {
		this.currency = currency;
	}

	public String getKilos() {
		return kilos;
	}

	public void setKilos(String kilos) {
		this.kilos = kilos;
	}

	public String getVolume() {
		return volume;
	}

	public void setVolume(String volume) {
		this.volume = volume;
	}

	public String getIncotermCodeID() {
		return incotermCodeID;
	}

	public void setIncotermCodeID(String incotermCodeID) {
		this.incotermCodeID = incotermCodeID;
	}

	public String getIncotermName() {
		return incotermName;
	}

	public void setIncotermName(String incotermName) {
		this.incotermName = incotermName;
	}

	public String getComment1() {
		return comment1;
	}

	public void setComment1(String comment1) {
		this.comment1 = comment1;
	}

	public String getComment2() {
		return comment2;
	}

	public void setComment2(String comment2) {
		this.comment2 = comment2;
	}

	public String getTransportID() {
		return transportID;
	}

	public void setTransportID(String transportID) {
		this.transportID = transportID;
	}
	
	
	

	

}
